<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:p="http://primefaces.org/ui" xmlns:a4j="http://richfaces.org/a4j"
	xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<f:metadata>
 		<f:event listener="#{DuyurularBean.verifyProducer}" type="preRenderView"/>		
	</f:metadata>
</h:head>
<h:body>
	<ui:composition template="template.xhtml">

		<ui:define name="title">mehmet emmy</ui:define>
		<ui:define name="body">
			<c:if test="${sessionScope.currentKullanici.grup != 2}">
				<script language="javascript">
                    	alert("bu sayfaya erişim yetkiniz yoktur.")
    					redirectPage();
	  	 			</script>
			</c:if>			
			<h:form id="formDuyuruList">
				
				<p:growl id="msgs" showDetail="true" />
				<c:choose>
					<c:when test="${DuyurularBean.duyuruIslem &amp;&amp; 
						DuyurularBean.selectedDuyuru.sirketprofil.firmaid==SirketprofilBean.currentSirketpro.firmaid}">
						<p:commandButton id="backButton" value="Geri Dön" icon="ui-icon-search"
									actionListener="#{DuyurularBean.duyuruIslem(false)}"
									update=":formDuyuruList" />
						<h:panelGrid columns="2">

							<h:outputLabel value="Firma Adı" />
							<h:inputText  id="firmaAd" 
									value="#{DuyurularBean.selectedDuyuru.sirketprofil.firmaAd}" 
									disabled="true" readonly="true"/>
							
							<h:outputLabel value="Başlık" />
							<h:inputText  id="baslik" 
									value="#{DuyurularBean.selectedDuyuru.baslik}"/>					
									
							<h:outputLabel value="Açıklama" />
							<h:inputText  id="aciklama" 
									value="#{DuyurularBean.selectedDuyuru.aciklama}"/>
									
							<h:outputLabel value="Tarih" />
							<h:inputText  id="tarih" 
									value="#{DuyurularBean.selectedDuyuru.tarih}"/>
									
							<h:outputLabel value="Kimler için" />
							<h:inputText  id="kimin" 
									value="#{DuyurularBean.selectedDuyuru.kimlericin}"/>
							
							<h:outputLabel value="Önem Derecesi" />
							<h:inputText  id="önemi" 
									value="#{DuyurularBean.selectedDuyuru.onemDerecesi}"/>
							
							<h:outputLabel/>		
							<p:commandButton value="Save" icon="ui-icon-disk"
								actionListener="#{DuyurularBean.duyuruIslem(false)}"
								action="#{DuyurularBean.SaveOrUpdate}" update=":formDuyuruList"/>
						</h:panelGrid>
					</c:when>
					<c:otherwise>
						<p:dataTable id="duyuruTable" var="duyuru" widgetVar="duyurularTable"
							emptyMessage="Not found with given criteria"
							value="#{DuyurularBean.duyuruList}" tableStyle="width:auto"
							paginator="true" rows="10" liveScroll="true"
							rowKey="#{duyuru.duyuruid}"
							selection="#{DuyurularBean.selectedDuyuru}"
							selectionMode="single">
							
							<f:facet name="header">
								<p:outputPanel>
									<h:outputText value="Search all fields:" />
									<p:inputText id="globalFilter" onkeyup="duyurularTable.filter()"
										style="width:150px" />
								</p:outputPanel>
							</f:facet>
							
							<p:column headerText="Firma Adı" filterBy="#{duyuru.sirketprofil.firmaAd}" 
								filterMatchMode="contains" footerText="contains" style="width:100px" >
								<h:outputText value="#{duyuru.sirketprofil.firmaAd}" />
							</p:column>

							<p:column headerText="Başlık" style="width:100px"
								filterMatchMode="contains" footerText="contains" 
								filterBy="#{duyuru.baslik}">
								<h:outputText value="#{duyuru.baslik}" />
							</p:column>

							<p:column headerText="Açıklama" style="width:100px"
								filterMatchMode="contains" footerText="contains"
								filterBy="#{duyuru.aciklama}">
								<h:outputText value="#{duyuru.aciklama}" />
							</p:column>

							<p:column headerText="Tarih" style="width:100px"
								filterMatchMode="contains" footerText="contains"
								filterBy="#{duyuru.tarih}">
								<h:outputText value="#{duyuru.tarih}" style="color:red" />
							</p:column>

							<f:facet name="footer">
								<p:commandButton id="editButton" value="Edit" icon="ui-icon-pencil"
									actionListener="#{DuyurularBean.duyuruIslem(true)}"
									update=":formDuyuruList" />
							</f:facet>
							<f:facet name="footer">
								<p:commandButton id="deleteButton" value="Delete" icon="ui-icon-trash" 
									actionListener="#{DuyurularBean.deleteView}"
									update=":formDuyuruList" />
							</f:facet>
							<f:facet name="footer">
								<p:commandButton id="newButton" value="Add New" icon="ui-icon-document" 
									action="#{DuyurularBean.viewNew}"
									update=":formDuyuruList" />
							</f:facet>
						</p:dataTable>
					</c:otherwise>
				</c:choose>
			</h:form>
		</ui:define>
	</ui:composition>
</h:body>
</html>